package com.cuitrip.business.user.ui;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.cuitrip.business.home.recommend.model.RecommendTravelTrip;
import com.cuitrip.business.tripservice.proxy.PriceProxy;
import com.cuitrip.service.R;
import com.lab.adapter.BaseHolderView;
import com.lab.adapter.IAdapterData;
import com.lab.utils.ImageHelper;
import com.lab.utils.NumberUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ak on 15/10/15.
 */
public class TripHolderView extends BaseHolderView {


    @Bind(R.id.service_pic)
    public ImageView mImage;
    @Bind(R.id.service_name)
    public TextView serviceName;
    @Bind(R.id.service_money)
    public TextView serviceMoney;
    @Bind(R.id.service_score)
    public RatingBar ratingBar;
    @Bind(R.id.fav_count)
    public TextView favCount;

    public TripHolderView(Context context) {
        super(context, R.layout.trip_item);
    }


    @Override
    public void initView(View rootView) {
        this.setClickable(true);
        ButterKnife.bind(this);
    }

    @Override
    public void bindData(IAdapterData data, int position) {
        if (data instanceof RecommendTravelTrip) {
            RecommendTravelTrip item = (RecommendTravelTrip) data;
            ImageHelper.displayCtImage(item.getServicePicUrl(), mImage, null);
            try {
                ratingBar.setRating(NumberUtils.parseFloat(item.getServiceScore()));
            } catch (Exception e) {
            }
            serviceName.setText(item.getServiceName());
            favCount.setText(String.valueOf(item.getLikesNum()));
            favCount.setTextColor(getResources().getColor(R.color.ganshi_ded8d7));
            serviceMoney.setText(PriceProxy.getInstance().priceFormatText(item.getPriceType(), item.getShowCurrency(), item.getShowPrice()));
        }
    }
}
